package com.joshjung.hover.functional
{
    import com.joshjung.hover.interfaces.IKeyboardResponder;

    import flash.utils.Dictionary;

    /**
     *
     * @author jjung
     */
    public class KeyboardResponder implements IKeyboardResponder
    {
        //---------------------------------------------------------------------
        //
        //  Variables
        //
        //---------------------------------------------------------------------
        public var keysDown : Dictionary = new Dictionary();
        public var keyUps : Dictionary = new Dictionary();
        public var keyDowns : Dictionary = new Dictionary();

        //---------------------------------------------------------------------
        //
        //  Constructor
        //
        //---------------------------------------------------------------------
        /**
         *  Constructor
         */
        public function KeyboardResponder()
        {
        }

        //---------------------------------------------------------------------
        //
        //  Methods
        //
        //---------------------------------------------------------------------
        public function reset() : void
        {
            keyDowns = new Dictionary();
            keyUps = new Dictionary();
        }

        public function keyDown(keyCode : uint) : void
        {
            keyDowns[keyCode] = true;
            keysDown[keyCode] = true;
        }

        public function keyUp(keyCode : uint) : void
        {
            keyUps[keyCode] = true;

            delete keysDown[keyCode];
        }
    }
}
